package com.aaa.behind.controller;


import com.aaa.behind.service.ITbZoneBusinessService;
import com.aaa.entity.TbZoneBusiness;
import com.aaa.util.PageInfo;
import com.aaa.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 专区课程关联表 前端控制器
 * </p>
 *
 * @author whj
 * @since 2023-02-01
 */
@RestController
@RequestMapping("/tb-zone-business")
public class TbZoneBusinessController {

    @Autowired
    private ITbZoneBusinessService tbZoneBusinessService;

    @PostMapping("managementZone")
    public Result managementZone(@ModelAttribute PageInfo pageInfo, TbZoneBusiness tbZoneBusiness){
        return new Result(tbZoneBusinessService.managementZone(pageInfo,tbZoneBusiness));
    }

    @GetMapping("changeStatus/{id}/{isDisable}")
    public Result changeStatus(@PathVariable String id,@PathVariable Integer isDisable){
        TbZoneBusiness tbZoneBusiness = new TbZoneBusiness();
        tbZoneBusiness.setId(id);
        tbZoneBusiness.setIsDisable(isDisable);
        return new Result(tbZoneBusinessService.saveOrUpdate(tbZoneBusiness));
    }


    @GetMapping("changeSort/{id}/{sort}")
    public Result changeSort(@PathVariable String id,@PathVariable Integer sort){
        TbZoneBusiness tbZoneBusiness = new TbZoneBusiness();
        tbZoneBusiness.setId(id);
        tbZoneBusiness.setSort(sort);
        return new Result(tbZoneBusinessService.saveOrUpdate(tbZoneBusiness));
    }

    @GetMapping("deleteZoneBusiness/{id}")
    public Result deleteZoneBusiness(@PathVariable String id){
        return new Result(tbZoneBusinessService.removeById(id));
    }

}

